Implement policy validation engine with ESLint/Prettier integration#1
Merged
Implement policy validation engine with ESLint/Prettier integration#1
Conversation
- Define Engine interface with Init/Validate/GetCapabilities/Close - Add ValidationResult, Violation, Rule types - Add EngineCapabilities for describing engine features - Add helper methods for safe config access (GetString, GetInt, etc.)
- Define Adapter interface for wrapping external tools - Add CheckAvailability, Install, GenerateConfig, Execute, ParseOutput - Add SubprocessExecutor for running tools as child processes - Add ToolOutput and Violation types - Adapters will wrap tools like ESLint, Prettier, etc.
- Add Registry for managing available engines - Support lazy initialization (create on first Get) - Thread-safe with RWMutex - Global registry accessible via Global() - MustRegister helper for init() registration
- Add tests for Rule helper methods (GetString, GetInt, etc.) - Add tests for Violation.String() formatting - Add tests for Registry (register, get, lazy init, duplicates) - All tests passing
- Add Adapter with CheckAvailability, Install, GenerateConfig - Support local (tools dir) and global ESLint installation - Auto-install via npm if not found - Add config generator for pattern/length/style rules - Map Symphony rules to ESLint rules: - Pattern: id-match, no-restricted-syntax, no-restricted-imports - Length: max-len, max-lines, max-params, max-lines-per-function - Style: indent, quotes, semi
- Implement execute() to run ESLint with generated config - Write config to temp file, execute ESLint with --format json - Support both local (tools dir) and global ESLint - Implement parseOutput() to convert ESLint JSON to violations - Map ESLint severity (0/1/2) to string (info/warning/error)
Pattern Engine: - Validates naming conventions (id-match) - Detects forbidden patterns (no-restricted-syntax) - Controls imports (no-restricted-imports) - Delegates to ESLint adapter Length Engine: - Validates line length (max-len) - Validates file length (max-lines) - Validates function length (max-lines-per-function) - Validates parameter count (max-params) - Delegates to ESLint adapter Both engines: - Auto-install ESLint if not found - Support JavaScript/TypeScript/JSX/TSX - Filter files by language selector - Convert adapter violations to core violations
- Add builtin.go to register engines in init() - Add unit tests for ESLint config generation - Add unit tests for ESLint output parsing - All tests passing
- Add bad-naming.js with intentional violations - Add good-code.js with correct code - Add pattern engine integration test - Test validates naming conventions via ESLint - Test skips if ESLint not available
- Add Adapter with CheckAvailability, Install - Support --check mode (validation) and --write mode (autofix) - Generate .prettierrc.json from style rules - Map style options: tabWidth, semi, singleQuote, trailingComma - Parse Prettier output (file list when formatting needed) - Auto-install via npm if not found
Style Engine: - Validates with ESLint (indent, quotes, semi rules) - Auto-fixes with Prettier (--write mode) - Supports diff preview before applying fixes Features: - Validation: ESLint respects user config - Autofix: Prettier for fast formatting - Diff generation: Preview changes before applying - Two-tier strategy: validate strictly, fix quickly Autofix methods: - Autofix(): Apply Prettier formatting - GenerateDiff(): Preview changes without writing
- Register style engine in builtin.go - Add Prettier config generation tests - Add bad-style.js (unprettified code) - Add good-style.js (prettified code) - All tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Symphony CLI의 핵심 검증 시스템을 구현했습니다.
Engine 추상화 계층, 4개의 엔진(Pattern, Length, Style, AST)과 2개의 어댑터(ESLint, Prettier)를 포함하며, 언어 중립적 인터페이스와 테스트를 제공합니다.
자연어 기반 규칙, LLM 통합, 외부 도구 재활용을 목표로 설계되었습니다.
Changes